package com.ruoyi.web.wx.controller.pay;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.wx.pay.WxPayUserType;
import com.ruoyi.system.service.wx.pay.IWxPayUserTypeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户支付常用类型Controller
 * 
 * @author mic
 * @date 2023-08-29
 */
@RestController
@RequestMapping("/payUserType")
public class WxPayUserTypeController extends BaseController
{
    @Autowired
    private IWxPayUserTypeService wxPayUserTypeService;

    /**
     * 查询用户支付常用类型列表
     */
    @PreAuthorize("@ss.hasPermi('payUserType:payUserType:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxPayUserType wxPayUserType)
    {
        startPage();
        List<WxPayUserType> list = wxPayUserTypeService.selectWxPayUserTypeList(wxPayUserType);
        return getDataTable(list);
    }

    /**
     * 导出用户支付常用类型列表
     */
    @PreAuthorize("@ss.hasPermi('payUserType:payUserType:export')")
    @Log(title = "用户支付常用类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxPayUserType wxPayUserType)
    {
        List<WxPayUserType> list = wxPayUserTypeService.selectWxPayUserTypeList(wxPayUserType);
        ExcelUtil<WxPayUserType> util = new ExcelUtil<WxPayUserType>(WxPayUserType.class);
        util.exportExcel(response, list, "用户支付常用类型数据");
    }

    /**
     * 获取用户支付常用类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('payUserType:payUserType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(wxPayUserTypeService.selectWxPayUserTypeById(id));
    }

    /**
     * 新增用户支付常用类型
     */
    @PreAuthorize("@ss.hasPermi('payUserType:payUserType:add')")
    @Log(title = "用户支付常用类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxPayUserType wxPayUserType)
    {
        return toAjax(wxPayUserTypeService.insertWxPayUserType(wxPayUserType));
    }

    /**
     * 修改用户支付常用类型
     */
    @PreAuthorize("@ss.hasPermi('payUserType:payUserType:edit')")
    @Log(title = "用户支付常用类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxPayUserType wxPayUserType)
    {
        return toAjax(wxPayUserTypeService.updateWxPayUserType(wxPayUserType));
    }

    /**
     * 删除用户支付常用类型
     */
    @PreAuthorize("@ss.hasPermi('payUserType:payUserType:remove')")
    @Log(title = "用户支付常用类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wxPayUserTypeService.deleteWxPayUserTypeByIds(ids));
    }
}
